package com.lge.pitchingcoins.util.lockkey;

import android.app.Activity;
import android.view.WindowManager;

public class HomeKeyLockForLessThanKK implements IHomeKeyLock {
    @Override
    public boolean setHomeKeyLock(boolean isLocked, IWindowManagerLayoutParams windowManagerLayoutParams, Activity activity) {
        if (isLocked) {
            int homeKeyValue = 0;
       
            try {
                homeKeyValue = WindowManager.LayoutParams.class.getDeclaredField("EXTEND_BYPASS_HOME_KEY").getInt(new WindowManager.LayoutParams());
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } finally {
                windowManagerLayoutParams.addLayoutParamExtendFlag(homeKeyValue);
            }
        } else {
            windowManagerLayoutParams.setLayoutParamExtendFlag(0);
        }
        
        activity.getWindow().setAttributes(windowManagerLayoutParams.getAttributes());    
        return true;
    }
}